package com.lc.zpyh.ui.activity.order;

import android.graphics.Color;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.widget.TextView;

import com.hjq.bar.TitleBar;
import com.lc.zpyh.R;
import com.lc.zpyh.app.AppActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class CommentSuccessfActivity extends AppActivity {
    @BindView(R.id.title_bar_top)
    TitleBar titleBarTop;
    @BindView(R.id.tv_sure)
    TextView tvSure;
    private CountDownTimer timer;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_commentsuccessf;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
        if (timer == null) {
            timer = new CountDownTimer(5000, 1000) {
                @Override
                public void onTick(long l) {

                 tvSure.setClickable(false);
                 tvSure.setText("确认("+l/1000+"S)");
                 tvSure.setTextColor(Color.WHITE);
                }

                @Override
                public void onFinish() {
                 //重新给Button设置文字
                 tvSure.setText("确认");
                 //设置可点击
                 tvSure.setClickable(true);
                 timer.cancel();
                }
            };
            timer.start();
        }
    }

    @OnClick(R.id.tv_sure)
    public void onClick() {
     finish();
    }

 @Override
 protected void onDestroy() {
  super.onDestroy();
  if (timer!=null){
   timer.cancel();
  }
 }
}
